class Person():
    name = ''
    age = 0

    def __init__(self, name):
        self.name = name

    def say(self):
        print('我是%s,我%s岁' % (self.name, self.age))


class Dog():
    name = ''
    age = 0

    def __init__(self, name):
        self.name = name

    def jiao(self):
        print('汪汪汪, 旺旺旺')
class Car():
    model = 'BMW'

p1 = Person('li')
p2 = Person('zhao')
p3 = Person('wang')
d1 = Dog('xiaohuang')
c1 = Car()
l = [p1,p2,p3,d1,c1]

for obj in l:
    if getattr(obj, 'say', None):   # 自省
        obj.say()
    elif getattr(obj, 'name', None):
        print(obj.name+'不会说话')
    else:
        print('他没有名字, 也不会说话')
